using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using TimeSheetBLL;

namespace TimeSheet.includes
{
    /// <summary>
    ///		Summary description for Header.
    /// </summary>
    public abstract class Header : UserControl
    {
        protected Image Image2;
        protected Label lblMessage;
        protected HyperLink HyperLink1;
        protected LinkButton LinkButton1;
        protected HyperLink hlBillable;
        protected HyperLink hlNonBillable;
        protected Image Image1;

        private void Page_Load(object sender, EventArgs e)
        {
            User user = Session["User"] as User;
            if (user == null)
            {
                hlBillable.Visible = false;
                hlNonBillable.Visible = false;
            }
            else
            {
                lblMessage.Text = "<div align=\"right\">Logged in: " + user.FirstName +
                                  " " + user.LastName;
                hlBillable.NavigateUrl =
                    "../Admin/report/ViewUserProjectsReport.aspx?id=" + user.ID;
                hlNonBillable.NavigateUrl =
                    "../Admin/report/ViewUserNonChargeableReport.aspx?id=" + user.ID;
            }
        }

        #region Web Form Designer generated code

        protected override void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        ///		Required method for Designer support - do not modify
        ///		the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
            this.Load += new System.EventHandler(this.Page_Load);
        }

        #endregion

        private void LinkButton1_Click(object sender, EventArgs e)
        {
            Session["User"] = null;
            Session["Administrator"] = null;
            Response.Redirect("default.aspx");
        }
    }
}